package com.lxmes.jiesuan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.jiesuan.domain.XhDwhysq;
import com.lxmes.jiesuan.service.IXhDwhysqService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 单位会员申请Controller
 * 
 * @author ruoyi
 * @date 2023-03-30
 */
@RestController
@RequestMapping("/jiesuan/dwhysq")
public class XhDwhysqController extends BaseController
{
    @Autowired
    private IXhDwhysqService xhDwhysqService;

    /**
     * 查询单位会员申请列表
     */
    @PreAuthorize("@ss.hasPermi('jiesuan:dwhysq:list')")
    @GetMapping("/list")
    public TableDataInfo list(XhDwhysq xhDwhysq)
    {
        startPage();
        List<XhDwhysq> list = xhDwhysqService.selectXhDwhysqList(xhDwhysq);
        return getDataTable(list);
    }

    /**
     * 导出单位会员申请列表
     */
    @PreAuthorize("@ss.hasPermi('jiesuan:dwhysq:export')")
    @Log(title = "单位会员申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XhDwhysq xhDwhysq)
    {
        List<XhDwhysq> list = xhDwhysqService.selectXhDwhysqList(xhDwhysq);
        ExcelUtil<XhDwhysq> util = new ExcelUtil<XhDwhysq>(XhDwhysq.class);
        util.exportExcel(response, list, "单位会员申请数据");
    }

    /**
     * 获取单位会员申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiesuan:dwhysq:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(xhDwhysqService.selectXhDwhysqById(id));
    }

    /**
     * 新增单位会员申请
     */
    @PreAuthorize("@ss.hasPermi('jiesuan:dwhysq:add')")
    @Log(title = "单位会员申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XhDwhysq xhDwhysq)
    {
        return toAjax(xhDwhysqService.insertXhDwhysq(xhDwhysq));
    }

    /**
     * 修改单位会员申请
     */
    @PreAuthorize("@ss.hasPermi('jiesuan:dwhysq:edit')")
    @Log(title = "单位会员申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XhDwhysq xhDwhysq)
    {
        return toAjax(xhDwhysqService.updateXhDwhysq(xhDwhysq));
    }

    /**
     * 删除单位会员申请
     */
    @PreAuthorize("@ss.hasPermi('jiesuan:dwhysq:remove')")
    @Log(title = "单位会员申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(xhDwhysqService.deleteXhDwhysqByIds(ids));
    }
}
